//
//  SDP_CollectionViewCellForFindOutMore.m
//  PRO_B
//
//  Created by sp on 16/3/21.
//  Copyright © 2016年 宋平 . All rights reserved.
//

#import "SDP_CollectionViewCellForFindOutMore.h"
#import "SDP_modelForFindMore.h"
#import <SDWebImage/UIImageView+WebCache.h>


#define WIGHT  self.view.bounds.size.width
#define HEIGHT  self.view.bounds.size.height


@interface SDP_CollectionViewCellForFindOutMore ()

@property (nonatomic, retain)UIImageView *imageForFindMore;
@property (nonatomic, retain)UILabel *labelForFindMore;
@property (nonatomic, retain)UIView *viewForBackImage;

@end

@implementation SDP_CollectionViewCellForFindOutMore


/** 初始化 */

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self creatCellForFindMoreSubviews];
        
    }
    
    return self;

}

/** 创建子控件*/

- (void)creatCellForFindMoreSubviews{

    
    /**背景图片*/
    self.imageForFindMore = [[UIImageView alloc]init];
  //  self.imageForFindMore.backgroundColor = [UIColor brownColor];
    
    /** 图片上蒙一层暗色 */
   self.viewForBackImage = [[UIView alloc]init];
    self.viewForBackImage.backgroundColor = [UIColor darkGrayColor];
    self.viewForBackImage.alpha = 0.1;
    
    /** 主题 */
    self.labelForFindMore = [[UILabel alloc] init];
    self.labelForFindMore.font = [UIFont systemFontOfSize:13];
    self.labelForFindMore.textColor = [UIColor whiteColor];
    self.labelForFindMore.textAlignment = NSTextAlignmentCenter;
    self.labelForFindMore.backgroundColor = [UIColor clearColor];

    
    [self.contentView addSubview:self.imageForFindMore];
    [self.contentView addSubview:self.labelForFindMore];
    [self.imageForFindMore addSubview:self.viewForBackImage];

}


/** 赋值 */

- (void)passModelForFindMore: (SDP_ModelForFindMore *)model{
    
    // 主题
    NSString *textForName = [NSString stringWithFormat:@"# %@", model.name];
    self.labelForFindMore.text = textForName;
    
    // 图片
    [self.imageForFindMore sd_setImageWithURL:[NSURL URLWithString:model.bgPicture] placeholderImage:nil];

}



/** 布局 */

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    self.imageForFindMore.frame = self.contentView.frame  ;
    self.labelForFindMore.frame = CGRectMake(0, self.contentView.frame.size.height, self.contentView.frame.size.width,  self.contentView.frame.size.width/5);
    
    self.viewForBackImage.frame = self.imageForFindMore.frame;
    
    self.labelForFindMore.center = self.imageForFindMore.center;

}









@end
